editar = {
    addAboutFields:function(){
        $(".fielddesc, .required").click(
            function(){
                href = $(this).attr("href");
                $(href).jqm({});
                $(href).jqmShow();
                return false;
            }
        );
        return this;
    },
    addMoreFields:function(){
        $(".addfield").click(
            function(){
                href = $(this).attr("href").replace(/#/,".");
                clone = $(href).clone(true);
                clone.removeClass(href.replace(/\./,""));
                clone.removeClass("base");
                clone.removeClass("none");
                $(this).parent().after(clone);
                return false;
            }
        );
        return this;
    },
    addLessFieds: function(){
        $(".remove").click(
            function(){
                $(this).parent().remove();
                return false;
            }
        );
        return this;
    },
    addSuggest: function(){
        $(".othername").jSuggest({
            loadingText: "carregando...",
            url: "suggestion.html",
            type: "GET",
            data: "searchQuery",
            autoChange: true,
            fnChange: function(textBox){
                id = this.attr("id");
                $(textBox).parent().find(".otherid").val(id);
            }
        });
        return this;
    },
    addSubmit: function(){
        $(".salvar").click(function(){
            $(this.href).submit();
        });
        return this;
    }
};
$(function(){
    editar
    .addAboutFields()
    .addMoreFields()
    .addLessFieds()
    .addSuggest();
});